/**
 * 
 */
package br.com.consultsystems.negocio.impl.cadastro;

import java.util.Date;
import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import br.com.consultsystems.dominio.cadastro.Condominio;
import br.com.consultsystems.negocio.spec.cadastro.CondominioNegocio;
import br.com.consultsystems.persistencia.spec.cadastro.CondominioPersistencia;

/**
 * @author Moralles
 *
 */
@Stateless(name = "condominioNegocio")
public class CondominioNegocioImpl implements CondominioNegocio {

	@EJB
	private CondominioPersistencia condominioPersistencia;
	
	@Override
	public Condominio merge(Condominio t) throws Exception {
		
		if(t.getId() == null || t.getId() <= 0) {
			t.setDataCadastro(new Date());
		}
		return condominioPersistencia.merge(t);
	}

	@Override
	public Condominio retrieve(Long id) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void remove(Condominio t) throws Exception {
		t = this.merge(t);
		condominioPersistencia.remove(t);
	}

	@Override
	public void refresh(Condominio t) throws Exception {
		condominioPersistencia.refresh(t);
	}

	@Override
	public List<Condominio> retrieveAll() throws Exception {
		return condominioPersistencia.retrieveAll();
	}

	@Override
	public List<Condominio> retrieveByFilter(String nome) throws Exception {
		// TODO Auto-generated method stub
		return condominioPersistencia.retrieveByFilter(nome);
	}

	
}
